#ifndef myHandler_h__
#define myHandler_h__

#include "../inc/sky.h"

namespace Framework
{
	using namespace Sky;
	class myEventManager;
	class Message;
	class Handler;
	
	class Handler : public TreeNode
	{
		DECL_RTTI1(Handler,TreeNode);
	public:
		typedef MsgStatus (Handler::*EventId)(myEventManager* ,Message* );

		typedef fastdelegate::FastDelegate2<myEventManager*, Message*,MsgStatus> Handle;
		template <typename cls>
		NType::TVoid addHandler(MsgStatus (cls::*e)(myEventManager*,Message*),Handle h){_delegators.addHandler((EventId)e,h);}
		template <typename cls>
		NType::TVoid delHandler(MsgStatus (cls::*e)(myEventManager*,Message*),Handle h){_delegators.delHandler((EventId)e,h);}
		MsgStatus invokeHandler(myEventManager* manager,Message* msg);
	protected:
		DelegatorGroup<EventId,myEventManager* ,Message*> _delegators;
	};
}
#endif // myHandler_h__